/*
 * @Description: 新增与更新弹窗内容
 * @Author: Zzt
 * @Date: 2022-12-21 17:13:30
 * @LastEditTime: 2023-01-03 14:38:39
 */
import { fetchAllUnit } from '@/api/units';
import { Form, Input, Select } from 'antd';
import TextArea from 'antd/lib/input/TextArea';
import { useEffect, useState } from 'react';
const FromList = (props: any) => {
  // 加载时获取全宗列表，获取成功后默认选中第一条并把第一条返回出去
  const [unitList, setUnitList] = useState();
  useEffect(() => {
    fetchAllUnit({}).then((res) => {
      console.log(res);
      const unitList = res.data;
      setUnitList(unitList);
    });
  }, []);
  return (
    <>
      <Form.Item name="name" label="年检名称" rules={[{ required: true }]}>
        <Input placeholder="请填写年检名称" />
      </Form.Item>
      <Form.Item label="接收单位" name="guidanceUnitId" required>
        <Select options={unitList} fieldNames={{ label: 'unitName', value: 'id' }} />
      </Form.Item>
      <Form.Item name="year" label="所属年度" rules={[{ required: true }]}>
        <Input placeholder="请选择年度" />
      </Form.Item>
      <Form.Item label="说明" name="remark">
        <TextArea
          maxLength={2000}
          placeholder={'备注信息描述，最多可填写2000字'}
          showCount={true}
        ></TextArea>
      </Form.Item>
    </>
  );
};
export default FromList;
